<html>
<head>
<title>Downloader</title>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://prashanthca.tk/ticket/jquery.placeholder.js"></script>
<script>
$(function(){
	$(".btn").click(function(){
				$("#cool").submit();
			});
	$(".pointer").click(function(){
				$(this).fadeOut("fast");
				$("#cfn").fadeIn("normal");
			});
	$("#url").placeholder("URL",true);
	$("#ext").placeholder("File Extension",true);
	$("#cfn").placeholder("Custom File Name",true);			
	});
</script>
<style>
@import url('Fonts/Gandhi/stylesheet.css');
@import url('http://fonts.googleapis.com/css?family=Fredoka+One');
body{background:#f2f2f2;}
.text{
border: 1px solid #BFBFBF;
border-radius: 2px;
box-sizing: border-box;
color: #444;
font: 16px GandhiSansRegular;
margin: 10px;
height:45px;
width:50%;
padding: 3px;
padding-bottom: 4px;
margin-left:20px;
margin-top:6px;
}
.text:active{
-webkit-transition: border-color 200ms;
   border-color: rgb(77, 144, 254);
  outline: none;
}
.text:focus{
  outline: none;
}
.btn{
	color: #6e6e6e;
    font: 17px GandhiSansRegular, Arial, sans-serif;
    text-decoration: none;
    padding: 7px 12px;
    position: relative;
    display: inline-block;
    text-shadow: 0 1px 0 #fff;
    -webkit-transition: border-color .218s;
    -moz-transition: border .218s;
    -o-transition: border-color .218s;
    transition: border-color .218s;
    background: #f3f3f3;
    background: -webkit-gradient(linear,0% 40%,0% 70%,from(#F5F5F5),to(#F1F1F1));
    background: -moz-linear-gradient(linear,0% 40%,0% 70%,from(#F5F5F5),to(#F1F1F1));
    border: solid 1px #dcdcdc;
    border-radius: 2px;
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
    margin: 15px;
    margin-left:20px;
margin-top:4px;
cursor:pointer;
}
.btn:hover {
    color: #333;
    border-color: #999;
    -moz-box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
 -webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.btn:active {
    color: #000;
    border-color: #444;
}
.heading1{
font-family: Fredoka One;
font-weight:bold;
font-size:25px;
color:#333;
margin:10px;
margin-left:20px;
}
.subhead{
font-family: GandhiSansRegular;
font-size:16px;
color:#777;
margin:10px;
margin-left:19px;
margin-top:10px;
}
.pointer{
font-family: GandhiSansRegular;
font-size:16px;
color:rgb(4,0,243);
margin:10px;
margin-left:19px;
margin-top:-15px;
cursor:pointer;
}
.pointer:hover{
text-decoration:underline;
}
#cfn{
display:none;
}
</style>
</head>
<body>
<?php
ini_set('max_execution_time','600');
if($_GET['u'])
{
$i=1;
$url=$_GET['u'];
$ext=$_GET['ext'];
$fn=$_GET['fn'];
if($fn!=NULL)
$local_file=$fn;
else if($ext)
$local_file=basename($url).".".$ext;
else
$local_file=basename($url);

$fp = fopen($local_file,"w");
$sp = fopen($url,"rb");
$contents="";
while($i<=4194803)
{
$bit = fread($sp,$i);
$contents.=$bit;
$i++;
}
fwrite($fp,$contents,$i);
fclose($fp);
fclose($sp);
}
?>
<form method="get" action="" id="cool">
<div class="heading1">PHP Downloader</div>
<div class="subhead">Download files onto the server</div>
<input type="text" class="text" id="url" name="u"><br>
<br><input type="text" class="text" id="ext" name="ext"><br>
<br><input type="text" class="text" id="cfn" name="fn"><br>
<br><span class="pointer">+ Add Custom Name</span><br>
<br><span class="btn">Submit<br>
</form>
</body>
</html>